﻿Imports System.Data.OleDb

Public Class accMaster
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub bt_AccMaster_Click(sender As Object, e As EventArgs) Handles bt_AccMaster.Click
        Dim oleDbConn As New OleDbConnection(ConfigurationManager.ConnectionStrings("ClaimsConnectionString").ConnectionString)

        Dim SqlString As String = "Insert Into Form6 ( employerNbr, workerNRC, reporterPosition, transactionDate, accidentDate, lengthServiceYears,lengthServiceMonths, " & _
                                  " subContractorName,subContractorAddress, priorDefect, priorDefectDetails, " & _
                                  "basicWageHour, basicWageShift, basicWageWeek, basicWageTicket, basicWageMonth, workingHoursWeek, workingHoursShift, " & _
                                  " previousCompensation, previousEmploymentDate, previousEmployer, accidentSite, accidentTime, dateAccidentReported, timeAccidentReported, nonReportExplain, accidentDescription, accidentResult, " & _
                                  "accidentResultStatement, accidentViolation, accidentDrunk, accidentContravention, accidentCauseStatement, accidentWitness," & _
                                  "accidentWitnessAddress, accidentWitnessTelNbr, accidentOtherAction, accidentOtherActionName," & _
                                  "accidentOtherActionAddress, accidentOtherActionEmail, accidentOtherActionTelNbr, officialNotice," & _
                                  "policeStationName, natureOfInjury, ceaseWorkDate, ceaseWorkTime, monthsOffDuty, weeksOffDuty, " & _
                                  "daysOffDuty, doctorName, doctorAddress, hospitalName, hospitalAddress, lengthServiceWeeks)" & _
                                  " Values (@f1, @f2, @f3, @f4, @f22, @f5, @f6, @f7, @f8, @f9, @f10, @f11, @f12, @f13, @f14, @f15, @f16, @f17, @f18, @f19, @f20, @f21, " & _
                                  " @f23, @f24, @f25, @f26, @f27, @f28, @f29, @f30, @f31, @f32, @f33, @f34, @f35, @f36, @f37, @f38, @f39, @f40, @f41, @f42, @f43, @f44, " & _
                                   " @f45, @f46, @f47, @f48, @f49, @f50, @f51, @f52, @f53, @f54)"
        ''                                  " previousEmploymentDate f19, accidentTime f23, dateAccidentReported f24, timeAccidentReported f25  ) " & _
        ''                                  "  " & _
        ''                                  " ceaseWorkDate f45, ceaseWorkTime f46, " & _


        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", "2226050")
        cmd.Parameters.AddWithValue("@f2", tb_workerNRC.Text)
        cmd.Parameters.AddWithValue("@f3", tb_reporterPosition.Text)
        cmd.Parameters.AddWithValue("@f4", DateTime.Now)
        cmd.Parameters.AddWithValue("@f22", tb_accidentDate.Text)
        cmd.Parameters.AddWithValue("@f5", tb_lengthServiceYears.Text)

        cmd.Parameters.AddWithValue("@f6", tb_lengthServiceMonths.Text)
        cmd.Parameters.AddWithValue("@f7", tb_subContractorName.Text)
        cmd.Parameters.AddWithValue("@f8", tb_subContractorAddress.Text)
        cmd.Parameters.AddWithValue("@f9", rbl_priorDefect.SelectedValue)
        cmd.Parameters.AddWithValue("@f10", tb_priorDefectDetails.Text)
        cmd.Parameters.AddWithValue("@f11", tb_basicWageHour.Text)
        cmd.Parameters.AddWithValue("@f12", tb_basicWageShift.Text)
        cmd.Parameters.AddWithValue("@f13", tb_basicWageWeek.Text)
        cmd.Parameters.AddWithValue("@f14", tb_basicWageTicket.Text)
        cmd.Parameters.AddWithValue("@f15", tb_basicWageMonth.Text)
        cmd.Parameters.AddWithValue("@f16", tb_workingHoursWeek.Text)
        cmd.Parameters.AddWithValue("@f17", tb_workingHoursShift.Text)
        cmd.Parameters.AddWithValue("@f18", rbl_previousCompensation.SelectedValue)
        cmd.Parameters.AddWithValue("@f19", tb_previousEmploymentDate.Text)
        cmd.Parameters.AddWithValue("@f20", tb_previousEmployer.Text)
        cmd.Parameters.AddWithValue("@f21", tb_accidentSite.Text)
        ''cmd.Parameters.AddWithValue("@f22", tb_accidentDate.Text)
        cmd.Parameters.AddWithValue("@f23", tb_accidentTime.Text)
        cmd.Parameters.AddWithValue("@f24", tb_dateAccidentReported.Text)
        cmd.Parameters.AddWithValue("@f25", tb_timeAccidentReported.Text)
        cmd.Parameters.AddWithValue("@f26", tb_nonReportExplain.Text)
        cmd.Parameters.AddWithValue("@f27", tb_accidentDescription.Text)
        cmd.Parameters.AddWithValue("@f28", rbl_accidentResult.SelectedValue)
        cmd.Parameters.AddWithValue("@f29", tb_accidentResultStatement.Text)
        cmd.Parameters.AddWithValue("@f30", rbl_accidentViolation.SelectedValue)
        cmd.Parameters.AddWithValue("@f31", rbl_accidentDrunk.SelectedValue)
        cmd.Parameters.AddWithValue("@f32", rbl_accidentContravention.SelectedValue)
        cmd.Parameters.AddWithValue("@f33", tb_accidentCauseStatement.Text)
        cmd.Parameters.AddWithValue("@f34", tb_accidentWitness.Text)
        cmd.Parameters.AddWithValue("@f35", tb_accidentWitnessAddress.Text)
        cmd.Parameters.AddWithValue("@f36", tb_accidentWitnessTelNbr.Text)
        cmd.Parameters.AddWithValue("@f37", rbl_accidentOtherAction.SelectedValue)
        cmd.Parameters.AddWithValue("@f38", tb_accidentOtherActionName.Text)
        cmd.Parameters.AddWithValue("@f39", tb_accidentOtherActionAddress.Text)
        cmd.Parameters.AddWithValue("@f40", tb_accidentOtherActionEmail.Text)
        cmd.Parameters.AddWithValue("@f41", tb_accidentOtherActionTelNbr.Text)
        cmd.Parameters.AddWithValue("@f42", rbl_officialNotice.SelectedValue)
        cmd.Parameters.AddWithValue("@f43", tb_policeStationName.Text)
        cmd.Parameters.AddWithValue("@f44", tb_natureOfInjury.Text)
        cmd.Parameters.AddWithValue("@f45", tb_ceaseWorkDate.Text)
        cmd.Parameters.AddWithValue("@f46", tb_ceaseWorkTime.Text)
        cmd.Parameters.AddWithValue("@f47", tb_monthsOffDuty.Text)
        cmd.Parameters.AddWithValue("@f48", tb_weeksOffDuty.Text)
        cmd.Parameters.AddWithValue("@f49", tb_daysOffDuty.Text)
        cmd.Parameters.AddWithValue("@f50", tb_doctorName.Text)
        cmd.Parameters.AddWithValue("@f51", tb_doctorAddress.Text)
        cmd.Parameters.AddWithValue("@f52", tb_hospitalName.Text)
        cmd.Parameters.AddWithValue("@f53", tb_hospitalAddress.Text)
        cmd.Parameters.AddWithValue("@f54", tb_lengthServiceWeeks.Text)


        oleDbConn.Open()
        cmd.ExecuteNonQuery()
        Response.Redirect("workerConfirmation.aspx")

    End Sub

    Protected Sub tb_lengthOfServiceMonths_TextChanged(sender As Object, e As EventArgs) Handles tb_lengthServiceMonths.TextChanged

    End Sub

    Protected Sub tb_workerNRC_TextChanged(sender As Object, e As EventArgs) Handles tb_workerNRC.TextChanged
        Dim oleDbConn As New OleDbConnection(ConfigurationManager.ConnectionStrings("ClaimsConnectionString").ConnectionString)

        Dim SqlString As String = "Select workerName From Worker Where workerNRC = @f1"
        Dim sText As String = String.Empty
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", tb_workerNRC.Text)


        oleDbConn.Open()
        Dim dataReader = cmd.ExecuteReader()
        If Not dataReader.HasRows Then Response.Redirect("workerConfirmation.aspx")
        If dataReader.Read() Then
            tb_workerName.Text = dataReader("workerName")
        End If

        ''Response.Redirect("workerConfirmation.aspx")
    End Sub
End Class